﻿#ifndef ROBOTARMMONITOR_H
#define ROBOTARMMONITOR_H

#include <QObject>
#include <QtNetwork/QTcpSocket>
#include <algorithm>
#include <QThread>

class RobotArmMonitor : public QObject
{
    Q_OBJECT
public:
    explicit RobotArmMonitor(QObject *parent = nullptr);

    bool connectToMonitorHost(std::string host, int port);

    double robot_joint_pose[6];
    double robot_xyz_pose[6];
    int robot_state = -1;
    int robot_mode = -1;

    QString host_ip;


signals:
    void sig_finish();

public slots:

    //
    void slot_finish();

    //
    void run_monitor();

private:

    bool check_size(QByteArray& data);
    void update_joint_pose(QByteArray& data);
    void update_xyz_pose(QByteArray& data);
    void update_robot_state(QByteArray& data);
    void update_robot_mode(QByteArray& data);

private:
    QTcpSocket* monitor_socket_;

    bool run_flag = false;

};

#endif // ROBOTARMMONITOR_H
